package com.hanbit.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;

public class BeanNameImplement implements BeanName, BeanNameAware {//, BeanFactoryAware {
	private String beanName;
	// 스프링의 beanFactory 구현체를 저장할 객체 선언
	private BeanFactory beanFactory;

	public void begin() {
		System.out.println("사용자 초기화 메서드");
	}

	public void end() {
		System.out.println("사용자 소멸 메서드");
	}

	@Override
	public void lifeMethod() {
		System.out.println("비지니스 로직이 수행중입니다...");
		System.out.println("beanName : " + beanName);
	}

	// 빈 객체가 자기 자신의 이름 확인
	@Override
	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}

	// 객체가 생성될 때 스프링의 BeanFactory를 전달받는 메서드
//	@Override
//	public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
//		this.beanFactory = beanFactory;
//	}
}
